﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using Lawyer.Model;
namespace Lawyer.BLL
{
	/// <summary>
	/// ArchiveBaseInfo
	/// </summary>
	public partial class ArchiveBaseInfo
	{
		private readonly Lawyer.DAL.ArchiveBaseInfo dal=new Lawyer.DAL.ArchiveBaseInfo();
		public ArchiveBaseInfo()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string ArchiveID)
		{
			return dal.Exists(ArchiveID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(Lawyer.Model.ArchiveBaseInfo model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Lawyer.Model.ArchiveBaseInfo model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string ArchiveID)
		{
			
			return dal.Delete(ArchiveID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string ArchiveIDlist )
		{
			return dal.DeleteList(ArchiveIDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Lawyer.Model.ArchiveBaseInfo GetModel(string ArchiveID)
		{
			
			return dal.GetModel(ArchiveID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public Lawyer.Model.ArchiveBaseInfo GetModelByCache(string ArchiveID)
		{
			
			string CacheKey = "ArchiveBaseInfoModel-" + ArchiveID;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(ArchiveID);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (Lawyer.Model.ArchiveBaseInfo)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Lawyer.Model.ArchiveBaseInfo> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Lawyer.Model.ArchiveBaseInfo> DataTableToList(DataTable dt)
		{
			List<Lawyer.Model.ArchiveBaseInfo> modelList = new List<Lawyer.Model.ArchiveBaseInfo>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Lawyer.Model.ArchiveBaseInfo model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Lawyer.Model.ArchiveBaseInfo();
					if(dt.Rows[n]["ArchiveID"]!=null && dt.Rows[n]["ArchiveID"].ToString()!="")
					{
					model.ArchiveID=dt.Rows[n]["ArchiveID"].ToString();
					}
					if(dt.Rows[n]["FullName"]!=null && dt.Rows[n]["FullName"].ToString()!="")
					{
					model.FullName=dt.Rows[n]["FullName"].ToString();
					}
					if(dt.Rows[n]["Birthday"]!=null && dt.Rows[n]["Birthday"].ToString()!="")
					{
						model.Birthday=DateTime.Parse(dt.Rows[n]["Birthday"].ToString());
					}
					if(dt.Rows[n]["Telphone"]!=null && dt.Rows[n]["Telphone"].ToString()!="")
					{
					model.Telphone=dt.Rows[n]["Telphone"].ToString();
					}
					if(dt.Rows[n]["Fax"]!=null && dt.Rows[n]["Fax"].ToString()!="")
					{
					model.Fax=dt.Rows[n]["Fax"].ToString();
					}
					if(dt.Rows[n]["Address"]!=null && dt.Rows[n]["Address"].ToString()!="")
					{
					model.Address=dt.Rows[n]["Address"].ToString();
					}
					if(dt.Rows[n]["CFullName"]!=null && dt.Rows[n]["CFullName"].ToString()!="")
					{
					model.CFullName=dt.Rows[n]["CFullName"].ToString();
					}
					if(dt.Rows[n]["CBirthday"]!=null && dt.Rows[n]["CBirthday"].ToString()!="")
					{
						model.CBirthday=DateTime.Parse(dt.Rows[n]["CBirthday"].ToString());
					}
					if(dt.Rows[n]["CTelphone"]!=null && dt.Rows[n]["CTelphone"].ToString()!="")
					{
					model.CTelphone=dt.Rows[n]["CTelphone"].ToString();
					}
					if(dt.Rows[n]["CFax"]!=null && dt.Rows[n]["CFax"].ToString()!="")
					{
					model.CFax=dt.Rows[n]["CFax"].ToString();
					}
					if(dt.Rows[n]["CEmail"]!=null && dt.Rows[n]["CEmail"].ToString()!="")
					{
					model.CEmail=dt.Rows[n]["CEmail"].ToString();
					}
					if(dt.Rows[n]["CRelation"]!=null && dt.Rows[n]["CRelation"].ToString()!="")
					{
					model.CRelation=dt.Rows[n]["CRelation"].ToString();
					}
					if(dt.Rows[n]["BankFunds"]!=null && dt.Rows[n]["BankFunds"].ToString()!="")
					{
						model.BankFunds=decimal.Parse(dt.Rows[n]["BankFunds"].ToString());
					}
					if(dt.Rows[n]["BankAccount"]!=null && dt.Rows[n]["BankAccount"].ToString()!="")
					{
					model.BankAccount=dt.Rows[n]["BankAccount"].ToString();
					}
					if(dt.Rows[n]["CaseSource"]!=null && dt.Rows[n]["CaseSource"].ToString()!="")
					{
					model.CaseSource=dt.Rows[n]["CaseSource"].ToString();
					}
					if(dt.Rows[n]["PersonalDetail"]!=null && dt.Rows[n]["PersonalDetail"].ToString()!="")
					{
					model.PersonalDetail=dt.Rows[n]["PersonalDetail"].ToString();
					}
					if(dt.Rows[n]["PersonalNote"]!=null && dt.Rows[n]["PersonalNote"].ToString()!="")
					{
					model.PersonalNote=dt.Rows[n]["PersonalNote"].ToString();
					}
					if(dt.Rows[n]["FatherName"]!=null && dt.Rows[n]["FatherName"].ToString()!="")
					{
					model.FatherName=dt.Rows[n]["FatherName"].ToString();
					}
					if(dt.Rows[n]["FatherDOB"]!=null && dt.Rows[n]["FatherDOB"].ToString()!="")
					{
						model.FatherDOB=DateTime.Parse(dt.Rows[n]["FatherDOB"].ToString());
					}
					if(dt.Rows[n]["FatherNationality"]!=null && dt.Rows[n]["FatherNationality"].ToString()!="")
					{
					model.FatherNationality=dt.Rows[n]["FatherNationality"].ToString();
					}
					if(dt.Rows[n]["FatherContact"]!=null && dt.Rows[n]["FatherContact"].ToString()!="")
					{
					model.FatherContact=dt.Rows[n]["FatherContact"].ToString();
					}
					if(dt.Rows[n]["MotherName"]!=null && dt.Rows[n]["MotherName"].ToString()!="")
					{
					model.MotherName=dt.Rows[n]["MotherName"].ToString();
					}
					if(dt.Rows[n]["MotherDOB"]!=null && dt.Rows[n]["MotherDOB"].ToString()!="")
					{
						model.MotherDOB=DateTime.Parse(dt.Rows[n]["MotherDOB"].ToString());
					}
					if(dt.Rows[n]["MotherNationality"]!=null && dt.Rows[n]["MotherNationality"].ToString()!="")
					{
					model.MotherNationality=dt.Rows[n]["MotherNationality"].ToString();
					}
					if(dt.Rows[n]["MotherContact"]!=null && dt.Rows[n]["MotherContact"].ToString()!="")
					{
					model.MotherContact=dt.Rows[n]["MotherContact"].ToString();
					}
					if(dt.Rows[n]["SisterName"]!=null && dt.Rows[n]["SisterName"].ToString()!="")
					{
					model.SisterName=dt.Rows[n]["SisterName"].ToString();
					}
					if(dt.Rows[n]["SisterDOB"]!=null && dt.Rows[n]["SisterDOB"].ToString()!="")
					{
						model.SisterDOB=DateTime.Parse(dt.Rows[n]["SisterDOB"].ToString());
					}
					if(dt.Rows[n]["SisterContact"]!=null && dt.Rows[n]["SisterContact"].ToString()!="")
					{
					model.SisterContact=dt.Rows[n]["SisterContact"].ToString();
					}
					if(dt.Rows[n]["SisterNationality"]!=null && dt.Rows[n]["SisterNationality"].ToString()!="")
					{
					model.SisterNationality=dt.Rows[n]["SisterNationality"].ToString();
					}
					if(dt.Rows[n]["BrotherName"]!=null && dt.Rows[n]["BrotherName"].ToString()!="")
					{
					model.BrotherName=dt.Rows[n]["BrotherName"].ToString();
					}
					if(dt.Rows[n]["BrotherDOB"]!=null && dt.Rows[n]["BrotherDOB"].ToString()!="")
					{
						model.BrotherDOB=DateTime.Parse(dt.Rows[n]["BrotherDOB"].ToString());
					}
					if(dt.Rows[n]["BrotherNationality"]!=null && dt.Rows[n]["BrotherNationality"].ToString()!="")
					{
					model.BrotherNationality=dt.Rows[n]["BrotherNationality"].ToString();
					}
					if(dt.Rows[n]["BrotherContact"]!=null && dt.Rows[n]["BrotherContact"].ToString()!="")
					{
					model.BrotherContact=dt.Rows[n]["BrotherContact"].ToString();
					}
					if(dt.Rows[n]["AgreedFees"]!=null && dt.Rows[n]["AgreedFees"].ToString()!="")
					{
						model.AgreedFees=decimal.Parse(dt.Rows[n]["AgreedFees"].ToString());
					}
					if(dt.Rows[n]["FeesClusive"]!=null && dt.Rows[n]["FeesClusive"].ToString()!="")
					{
						model.FeesClusive=int.Parse(dt.Rows[n]["FeesClusive"].ToString());
					}
					if(dt.Rows[n]["FeesFundable"]!=null && dt.Rows[n]["FeesFundable"].ToString()!="")
					{
						model.FeesFundable=int.Parse(dt.Rows[n]["FeesFundable"].ToString());
					}
					if(dt.Rows[n]["PersonalStatement"]!=null && dt.Rows[n]["PersonalStatement"].ToString()!="")
					{
					model.PersonalStatement=dt.Rows[n]["PersonalStatement"].ToString();
					}
					if(dt.Rows[n]["LawyerNote"]!=null && dt.Rows[n]["LawyerNote"].ToString()!="")
					{
					model.LawyerNote=dt.Rows[n]["LawyerNote"].ToString();
					}
					if(dt.Rows[n]["AssetAName"]!=null && dt.Rows[n]["AssetAName"].ToString()!="")
					{
					model.AssetAName=dt.Rows[n]["AssetAName"].ToString();
					}
					if(dt.Rows[n]["AssetAWorth"]!=null && dt.Rows[n]["AssetAWorth"].ToString()!="")
					{
						model.AssetAWorth=decimal.Parse(dt.Rows[n]["AssetAWorth"].ToString());
					}
					if(dt.Rows[n]["AssetANote"]!=null && dt.Rows[n]["AssetANote"].ToString()!="")
					{
					model.AssetANote=dt.Rows[n]["AssetANote"].ToString();
					}
					if(dt.Rows[n]["AssetADetail"]!=null && dt.Rows[n]["AssetADetail"].ToString()!="")
					{
					model.AssetADetail=dt.Rows[n]["AssetADetail"].ToString();
					}
					if(dt.Rows[n]["AssetBName"]!=null && dt.Rows[n]["AssetBName"].ToString()!="")
					{
					model.AssetBName=dt.Rows[n]["AssetBName"].ToString();
					}
					if(dt.Rows[n]["AssetBWorth"]!=null && dt.Rows[n]["AssetBWorth"].ToString()!="")
					{
						model.AssetBWorth=decimal.Parse(dt.Rows[n]["AssetBWorth"].ToString());
					}
					if(dt.Rows[n]["AssetBNote"]!=null && dt.Rows[n]["AssetBNote"].ToString()!="")
					{
					model.AssetBNote=dt.Rows[n]["AssetBNote"].ToString();
					}
					if(dt.Rows[n]["AssetBDetail"]!=null && dt.Rows[n]["AssetBDetail"].ToString()!="")
					{
					model.AssetBDetail=dt.Rows[n]["AssetBDetail"].ToString();
					}
					if(dt.Rows[n]["AssetCName"]!=null && dt.Rows[n]["AssetCName"].ToString()!="")
					{
					model.AssetCName=dt.Rows[n]["AssetCName"].ToString();
					}
					if(dt.Rows[n]["AssetCWorth"]!=null && dt.Rows[n]["AssetCWorth"].ToString()!="")
					{
						model.AssetCWorth=decimal.Parse(dt.Rows[n]["AssetCWorth"].ToString());
					}
					if(dt.Rows[n]["AssetCNote"]!=null && dt.Rows[n]["AssetCNote"].ToString()!="")
					{
					model.AssetCNote=dt.Rows[n]["AssetCNote"].ToString();
					}
					if(dt.Rows[n]["AssetCDetail"]!=null && dt.Rows[n]["AssetCDetail"].ToString()!="")
					{
					model.AssetCDetail=dt.Rows[n]["AssetCDetail"].ToString();
					}
					if(dt.Rows[n]["UpdatedBy"]!=null && dt.Rows[n]["UpdatedBy"].ToString()!="")
					{
					model.UpdatedBy=dt.Rows[n]["UpdatedBy"].ToString();
					}
					if(dt.Rows[n]["UpdatedDate"]!=null && dt.Rows[n]["UpdatedDate"].ToString()!="")
					{
						model.UpdatedDate=DateTime.Parse(dt.Rows[n]["UpdatedDate"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

